<template>
     <div>
        <el-breadcrumb separator-class="el-icon-arrow-right" separator="/">
            <el-breadcrumb-item :to="{ path: 'list' }">基础信息管理</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: 'list' }">用户管理</el-breadcrumb-item>
            <el-breadcrumb-item>新增用户</el-breadcrumb-item>
        </el-breadcrumb>
        <el-col :span="6" :offset="9" style="padding-top: 80px">
            <el-form ref="form" :model="form" label-width="120px" class="create">
                <el-form-item label="用户名">
                    <el-input v-model="form.username" placeholder="请输入用户名" ></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input type="password" auto-complete="off" v-model="form.password" placeholder="请输入密码"></el-input>
                </el-form-item>
                <el-form-item label="确认密码">
                    <el-input type="password" auto-complete="off" v-model="form.repassword" placeholder="请输入重复密码" ></el-input>
                </el-form-item>
                <el-form-item label="地址">
                    <el-input v-model="form.address" placeholder="请输入地址"></el-input>
                </el-form-item>
                <el-form-item label="联系电话">
                    <el-input v-model="form.phone" placeholder="请输入联系电话"></el-input>
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="onSubmit">保存</el-button>
                    <el-button @click="onCancel">取消</el-button>
                </el-form-item>
            </el-form>
        </el-col>
    </div>
</template>

<script>
    import { create } from '../../../../module/admin/basic/user'
    import { Message } from 'element-ui';
    export default {
        data () {
            return {
                form: {
                    username: '',
                    password: '',
                    repassword:'',
                    address: '',
                    phone:'',
                },
            }
        },
        mounted () {
            let _this = this;
          /*  this.$nextTick(function () {
                listGBM().then(data => {
                    _this.gbms = data;
                })
            })*/

        },
        methods: {
            onSubmit() {
                let _this = this;
                create(this.form).then(function (data) {
                    _this.$message({
                        type: 'success',
                        center: true,
                        message: '添加用户成功!'
                    });
                }).catch(function (error) {
                    _this.$message({
                        type: 'error',
                        center: true,
                        message: '添加用户失败!'
                    });
                });
                this.$router.push({
                    name: "admin-user-list"
                })
            },
            onCancel() {
                this.$router.push({
                    name: "admin-user-list"
                })
            },
            setStep(step) {
                this.form.process = step;
            },
            checkDcode(val, oleVal) {
                if (oleVal !== undefined) {


                }
            }
        },

    }
</script>

<style>
    .create .el-step {
        cursor: pointer;
    }

    .create .el-input, .create .el-date-editor.el-input {
        width: 200px;
    }

</style>
